*** This code replicates Appendix Section E. Why Deal Results are Inconclusive 

***Appendix Figure 1: Selecting responses by audience size suppresses the estimated effect of deals when all three responses are assumed to have similar effects in the data generating process.

** Start with a blank Stata instance, no need to load any data sets
*** Depending on the processor, it may take a while to finish the simulation 

capture program drop simulad
program define simulad, rclass
clear
set obs 100
qui gen audience =  1 + floor(20*uniform())
tab audience
qui gen tolerance = uniform()<.1
count if tolerance == 1
scalar tolno = r(N)
qui gen attack = 1 if audience >= 6 & tolerance==0 & uniform()<=.25
qui replace attack= 0 if attack==.
count if attack == 1
scalar attno = r(N)
qui gen deal = 1 if audience < 6 & tolerance==0 & uniform()<=.35
qui replace deal= 0 if deal==.
count if deal == 1
scalar dealno = r(N)

expand audience
qui gen startlatent2 = 1.5 -attack + deal + tolerance +2*rnormal()
qui gen start2 = startlatent2>=0

probit start2 attack deal tolerance

scalar attco = e(b)[1,1]
scalar dealco = e(b)[1,2]
scalar tolco = e(b)[1,3]

scalar attsd = sqrt(e(V)[1,1])
scalar dealsd = sqrt(e(V)[2,2])
scalar tolsd = sqrt(e(V)[3,3])

return scalar attco = attco 
return scalar attsd = attsd
return scalar attno = attno
return scalar dealco = dealco
return scalar dealsd =dealsd
return scalar dealno = dealno
return scalar tolco = tolco
return scalar tolsd = tolsd
return scalar tolno = tolno

end


set seed 1234567
simulate ano = r(attno) dno = r(dealno) tno = r(tolno) aco = r(attco) dco = r(dealco) tco = r(tolco) asd = r(attsd) dsd = r(dealsd) tsd = r(tolsd), dots(1000) reps(100000): simulad 

qui gen tatt = aco / asd
qui gen tdeal = dco / dsd
qui gen ttol = tco / tsd


twoway (kdensity ttol)  (kdensity tatt)  (kdensity tdeal), xline(-1.96 1.96, lpattern(dash))  legend(label(1 "Toleration") label(2 "Attack") label (3 "Deal")) xtitle("T-scores") title("Simulating the Significance of Regression Coefficients")